
new Vue({
    el:'#main',
    data:{

        account:{},
        newLoginPasswd:'',
        newReLoginPasswd:'',
        password:""
    },
    methods:{
        selectOne:function (aid) {
            axios({
                url: `manager/account/selectOne/${aid}`,
            }).then(response =>{
                this.account = response.data.obj;
                this.password = this.account.accountLoginPasswd;
                this.account.accountLoginPasswd='';
            }).catch(error =>{
                layer.msg(error.msg)
            })
        },
        showPwd:function(){
            console.log($("#chkModiPwd").is(':checked'));
            if ($("#chkModiPwd").is(':checked')){
                $('#divPwds').css('display','block')
            }else {
                $('#divPwds').css("display","none")
            }
        },

        doUpdate:function(){
            if (!($("#chkModiPwd").is(':checked'))){

                this.account.accountLoginPasswd = this.password;
            }else {
                if (this.account.accountLoginPasswd != this.password){
                    layer.msg('密码不正确');
                    return;
                }
                if (this.newLoginPasswd != this.newReLoginPasswd){
                    layer.msg("输入新密码不一致");
                    return;
                }

                this.account.accountLoginPasswd = this.newLoginPasswd;
            }
            if (this.account.accountRealName == undefined){
                layer.msg("姓名不能为空");
                return;
            }
            if (this.account.accountIdcardNo == undefined || this.account.accountIdcardNo.length !=18){
                layer.msg("请正确填写身份证号");
                return;
            }

            if (this.account.accountTelephone == undefined){
                layer.msg("电话不能为空");
                return;
            }


            axios({
                method:"post",
                url: `manager/account/doUpdate`,
                data: this.account
            }).then(res =>{
                parent.layer.message=res.data.msg;
                this.close();
            }).catch(error=>{
                layer.msg(error.msg)
            })
        },
        close:function () {
            let index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);//通过父窗口layer对象关闭子窗口

        }

    },
    created:function () {
        this.selectOne(parent.layer.aid);
    }

})